import createFileImage from '@/views/common/createFileImage'

export default {
  type: 'form',
  name: 'system-edit-form',
  api: {
    url: '/upms/admin/system/update',
    method: 'post',
    requestAdaptor: function(api, context){
      api.data.iconFileId = api.data.iconFile?.fileId;
      api.data.bannerFileId = api.data.bannerFile?.fileId;
      return {
        ...api,
        data : api.data
    };
    }
  },
  messages: {
    //不展示表单失败信息
    validateFailed: ''
  },
  body: [
    {
      type: 'hidden',
      name: 'id',
    },
    {
      type: 'group',
      body: [
        {
          type: 'input-text',
          name: 'systemName',
          label: '名称',
          required: true,
          maxLength: 50,
          validationErrors: {
            isRequired: '请输入名称'
          }
        },
        {
            type: 'input-text',
            name: 'systemCode',
            label: '编码',
            maxLength: 20,
            required: true,
            validationErrors: {
              isRequired: '请输入编码'
            }
        },
      ]
    },
    {
      type: 'input-text',
      name: 'title',
      label: '标题',
      maxLength: 50,
    },
    {
      type: 'input-text',
      name: 'subTitle',
      label: '副标题',
      maxLength: 100,
    },
    {
      type: 'group',
      body: [
        {
            type: 'input-text',
            name: 'basePath',
            label: '系统路径',
            maxLength: 100,
        },
        {
          type: 'input-text',
          name: 'group',
          label: '分组',
          maxLength: 20,
        },
      ]
    },
    {
      type: 'group',
      body: [
        {
            type: 'switch',
            name: 'showInPortal',
            label: 'portal页显示',
            value: '1',
            onText:'是',
            offText:'否',
            required: true,
            validationErrors: {
              isRequired: '请选择portal页显示'
            }
        },
        {
            type: 'input-number',
            name: 'sortNo',
            value: '0',
            label: '排序号',
            min: 0,
            max: 999999,
            maxLength: 6,
            required: true,
            validationErrors: {
              isRequired: '请输入排序号'
            }
        },
      ]
    },
    {
      type: 'group',
      body: [
        createFileImage('iconFileId', 'iconFile', '子系统icon', 2097152),
        createFileImage('bannerFileId', 'bannerFile', '子系统banner', 2097152),
      ]
    }
  ]
}